#include <functional>
#include <string>
#include <cstdio>
#include <iostream>
using namespace std;

const string opArr = "+-*/%";

class CalTask
{
public:
    using func_t = function<int(int, int, char)>;

public:
    CalTask()
    {
    }

    CalTask(int x, int y, char op, func_t func)
        : _x(x), _y(y), _op(op), _callfunc(func)
    {
    }

    // 运算符重载
    string operator()()
    {
        int res = _callfunc(_x, _y, _op);
        char buffer[1024];
        snprintf(buffer, sizeof buffer, "%d %c %d = %d", _x, _op, _y, res);
        return buffer;
    }

    // 在生产者这里拿到生产的数据
    string toTaskString()
    {
        char buffer[1024];
        snprintf(buffer, sizeof buffer, "%d %c %d = ?", _x, _op, _y);
        return buffer;
    }

private:
    int _x;
    int _y;
    func_t _callfunc;
    char _op;
};

int mymath(int x, int y, char op)
{
    int result = 0;
    switch (op)
    {
    case '+':
        result = x + y;
        break;
    case '-':
        result = x - y;
        break;
    case '*':
        result = x * y;
        break;
    case '/':
    {
        if (y == 0)
        {
            cout << "div zero error!" << endl;
            return -1;
        }
        else
        {
            result = x / y;
        }
    }
    break;
    case '%':
    {
        if (y == 0)
        {
            cout << "mod zero error!" << endl;
            return -1;
        }
        else
        {
            result = x % y;
        }
    }
    break;
    default:
        // do nothing
        break;
    }

    return result;
}